package jaoso.framework.web.struts;

import jaoso.framework.service.ServiceLocator;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.tiles.TilesRequestProcessor;

/**
 * @author 边缘孤客 edgeloner@yahoo.com.cn
 * @since 2004-12-28
 */
public class ServiceAutowireRequestProcessor extends TilesRequestProcessor
{
    /**
     * Override the base class method to return the autowireService action.
     *  
     */
    protected Action processActionCreate(HttpServletRequest request,
            HttpServletResponse response, ActionMapping mapping)
            throws IOException
    {
        Action action = super.processActionCreate(request, response, mapping);
        autowireService(action);
        return action;
    }

    private void autowireService(Action action)
    {
        ServiceLocator.getInstance().autowireService(action);
    }
}